import axios from 'axios';
import constants from '../constants/index';
import configs from './common/configs.js';
import { getTokenHeader } from '../../utils/utils';
import {message} from 'antd';
import Qs from 'qs';
const {GET_RECRUIT_DATA_SUCCESS} = constants;
const baseUrl = configs.baseUrl;
/**
 * 获取招新数据
 * @param {*} query 
 */
export function getDisplayDate(query = '') {
    return async dispatch => {
        try {
            let headers = getTokenHeader({});
            const data = (await axios.get(`${baseUrl}countSexAndWilling.do?${Qs.stringify(query)}`, {
                headers: headers,
            })).data;
            if(data.code==="SUCCESS")
            {
                dispatch({
                    type: GET_RECRUIT_DATA_SUCCESS,
                    willingCount:data.data.willingCount,
                    sexCount:data.data.sexCount
                });
            }
            else{
                message.error(data.msg);
            }
        } catch (error) {
            message.error('招新数据获取失败, 请稍后再试');
            
        }
    };
}